<%--
  Created by IntelliJ IDEA.
  User: qupen
  Date: 2016/11/9
  Time: 14:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="../../include/head.jsp">
    <jsp:param name="title" value="历史记录"/>
</jsp:include>

<jsp:include page="../../include/tenant_header.jsp"/>

<jsp:include page="../../include/tenant_sidebar.jsp"/>
<div class="content-wrapper content-wrapper-bg">
    <section class="content-header">
        <h4 class="page-title" style="display: inline-block">历史记录</h4>
        <a class="sie-head-add" href="javascript:getCreateProductPage();" style="margin-left:84px;">
            <i class="fa fa-plus" style="margin-right: 3px"></i>添加新记录
        </a>

        <div class="form-group has-success has-feedback" style="float: right;margin-right: 40px;">
            <input type="text" placeholder="搜索" class="form-control" id="inputSuccess2"
                   style="border-radius:5px;border-color:#aabfcb">
            <span class="glyphicon glyphicon-search form-control-feedback"></span>
        </div>
    </section>
    <section class="content">
        <div class="box box-primary table-header-line">
            <div class="box-body" style="padding: 0">
                <table class="table" id="product_list">
                    <thead>
                    <tr>
                        <th>机床id</th>
                        <th>产品总数</th>
                        <th>良品</th>
                        <th>次品</th>
                        <th>录入时间</th>
                        <th>录入者</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
        <%--</div>--%>
    </section>
</div>
<jsp:include page="../../include/foot.jsp"/>
<script>
    $(function () {
        var table = $('#product_list').DataTable({
            "dom": '<"datatable-header"<"dataTables_filter">l><"datatable-scroll"t><"datatable-footer dataTable-footer-padding"<"pull-left"i><"pull-right"p>>',
            paging: true,
            lengthChange: false,
            ordering: true,
            autoWidth: false,
            info: true,
            serverSide: false,
            fixedHeader: true,
            searching: true,
            aLengthMenu: [15],
            ajax: {
                url:"/partner/{tenant}/api/v1/product/list".replace("{tenant}", getKeyByUrl()),
                data:{
                    deviceId:"${deviceId}"
                },
                dataSrc: 'data'
            },
            columns: [
                {
                    data: 'uniqueId'
                },
                {
                    data: 'produtNum'
                },
                {
                    data: 'goodNum'
                },
                {
                    data: 'badNum'
                },
                {
                    data: 'startTime'
                },
                {
                    data: 'userName'
                },
                {
                    data:"",
                    render:function(data,type,full,meta){
                        var url = "/partner/{tenant}/product/edit?deviceId="+full.deviceId+"&startTime="+full.startTime;
                        url = url.replace("{tenant}", getKeyByUrl());
                        return "<div class='sie-btn-group'><a href='"+url+"' class='sie-btn-group'><i class='sie-btn-edit'></i><span>编辑</span></a></div>"
                    }
                }
            ],
            "language": {url:'/lang/datatable.chs.json'}
        });
        $('#inputSuccess2').bind('keyup', function (e) {
            table.search(this.value).draw();
        });
    });

    function getCreateProductPage(){
        var url = "/partner/{tenant}/device/addDate?deviceId=${deviceId}#deviceData";
        window.location.href = url.replace("{tenant}", getKeyByUrl());
    }
</script>